import request from '@/utils/request'

export function getArticleList (params) {
  return request({
    url: '/v1_1/articles',
    params
  })
}

export function getAllChannel () {
  return request({
    url: '/v1_0/channels'
  })
}
// 获取文章详情
export function getArticleDetail (id) {
  return request({
    url: '/v1_0/articles/' + id
  })
}

// 收藏文章
export function addCollected (target) {
  return request({
    url: '/v1_0/article/collections',
    method: 'POST',
    data: {
      target
    }
  })
}

// 取消收藏文章
export function removeCollected (target) {
  return request({
    url: '/v1_0/article/collections/' + target,
    method: 'DELETE'
  })
}

// 获取文章评论列表
export function getArticleComments (params) {
  return request({
    url: '/v1_0/comments',
    method: 'GET',
    params
  })
}
// 添加评论，评论回复
/**
 *
 * @param {*} data 参数：目标id：文章id/评论id ,文章内容，文章ID(评论文章的时候)
 * @returns
 */
export function addArticleComments (data) {
  return request({
    url: '/v1_0/comments',
    method: 'POST',
    data
  })
}
